package com.hnevc.gui;

import java.awt.CardLayout;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class CardLayoutDemo extends JFrame{
	
	private JPanel p;
	private JButton[] btns;
	private CardLayout cl;
	public CardLayoutDemo(){
		super("卡片布局");
		cl = new CardLayout();
		p = new JPanel(cl);
		JButton[] btns = new JButton[6];
		for(int i=0;i<btns.length;i++){
			btns[i] = new JButton("按钮"+(i+1));
		}
		for(int i=0;i<btns.length;i++){
			p.add("第"+i+"张卡片",btns[i]);
		}
		this.add(p);
		cl.show(p, "第3张卡片");
		this.setSize(200,200);
		this.setLocation(200,200);
		this.setVisible(true);
				
	}
	public static void main(String[] args) {
		new CardLayoutDemo();
	}

}
